class Animal:
    def __init__(self, name):
        self.name = name

    def speak(self):
        raise NotImplementedError("Subclasses must implement this method")

class Dog(Animal):
    def __init__(self, name, age):
        super().__init__(name)
        self.age = age

    def speak(self):
        return f"{self.name} says woof!"

class Cat(Animal):
    def speak(self):
        return f"{self.name} says meow!"

class Duck(Animal):
    def speak(self):
        pass

dog = Dog("Buddy", 3)
cat = Cat("Whiskers")
cat.age = 4
duck = Duck('鸭子')

print(dog.age)
print(dog.speak())  # 输出: Buddy says woof!
print(cat.age)  # 输出: Whiskers says meow!
print(cat.speak())  # 输出: Whiskers says meow!
print(duck.speak())  # 输出: Whiskers says meow!